package ui.creatorsscreen;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import ui.ScreenPanel;
import ui.ScreenPanelManager;
import ui.ScreenPanelManager.ID;
import ui.creatorsscreen.listeners.CreatorsPanelKeyListener;
import ui.creatorsscreen.listeners.CreatorsPanelMouseListener;
import ui.mainscreen.MainScreenPanel;

/**
 * Реализация панели создателей
 * 
 * @author Anton Nesterov, Rumata
 */
public class CreatorsScreenPanel extends ScreenPanel {

	private static final long serialVersionUID = 1L;

	/* TODO Перенести в пропетртис */
	String[] autors = {"Киричок Станислав", "Нестеров Антон", "Голенко Алексей"};

	/* Реализация шаблона - Синглтон */
	private static CreatorsScreenPanel instance;

	/**
	 * @return the instance
	 */
	public static synchronized CreatorsScreenPanel getInstance() {
		if (instance == null) {
			instance = new CreatorsScreenPanel();
		}
		return instance;
	}

	private CreatorsScreenPanel() {
		setOnCreateProperties("image/bgd.jpg");

		setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10),
			"Создатели", TitledBorder.CENTER, TitledBorder.TOP, new Font("Tahoma", 1, 20),
			new Color(30, 144, 255)));

		add(Box.createVerticalGlue());

		for (String autor : autors) {

			JLabel autorTitle = new JLabel();
			autorTitle.setFont(new Font("Tahoma", 1, 20));
			autorTitle.setForeground(new Color(255, 255, 255));
			autorTitle.setText(autor);

			BoxLayout boxCreators = new BoxLayout(this, BoxLayout.Y_AXIS);
			setLayout(boxCreators);
			autorTitle.setAlignmentX(Component.CENTER_ALIGNMENT);

			add(autorTitle);
			add(Box.createVerticalStrut(20));

		}

		add(Box.createVerticalGlue());
		
		/* Добавляем блок слушателей */
		addListeners();

	}

	@Override
	protected void addListeners() {
		addMouseListener(new CreatorsPanelMouseListener());
		addKeyListener(new CreatorsPanelKeyListener());
	}

}
